package com.js.study.datastructs.hash;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author JiangSen
 * @DATE 2023/12/28 10:17
 */
public class HashConflictDemo {
    public static void main(String[] args) {
        /*System.out.println("aa".hashCode());
        System.out.println("Aa".hashCode());
        System.out.println("你好".hashCode());
        System.out.println("-----------------");
        System.out.println(new Object().hashCode());
        System.out.println(new Object().hashCode());*/
        Set set = new HashSet();
        int hashCodeValue;
        for (int i = 0; i <= 190000; i++) {
            hashCodeValue = new Object().hashCode();
            if(set.contains(hashCodeValue)){
                System.out.println("发生hash冲突"+i+hashCodeValue);
                continue;
            }else{
                set.add(hashCodeValue);
            }
        }
        System.out.println(set.size());

    }
}
